<template>
  <div class="m-pagination">
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]" :page-size="pageSize" layout="total, prev, pager, next, sizes, jumper"
      :total="totalData">
    </el-pagination>
  </div>
</template>

<script>
import { reactive, toRefs } from "vue";

export default {
  name: "Pagination",
  props: {
    totalData: {
      type: Number,
      default: 0,
    },
    currentPage: {
      type: Number,
      default: 0,
    },
    pageSize: {
      type: Number,
      default: 0,
    },
  },
  setup(props, context) {
    const state = reactive({
      currentPage4: 4,
    });
    const handleSizeChange = (val) => {
      console.log(props);
      // props.pageSize = val
      context.emit("getPageData", val);
      // console.log(`每页 ${val} 条`)
    };
    const handleCurrentChange = (val) => {
      context.emit("getPageDatas", val);
      // console.log(`当前页: ${val}`)
    };
    return {
      ...toRefs(state),
      handleSizeChange,
      handleCurrentChange,
    };
  },
};
</script>

<style lang="less">
.m-pagination {
  text-align: center;
  .el-pagination__total {
    margin-right: 170px;
    font-size: 16px !important;
    line-height: 38px !important;
    color: #969696;
  }
  .el-pager li {
    width: 38px;
    height: 38px;
    line-height: 38px;
    margin: 0 6px;
    border: 1px solid #e3f6ff;
    border-radius: 6px;
    color: #31c0fd;
  }
  .el-pager li.active {
    color: #fff;
    background-color: #31c0fd;
  }
  .el-pager li.active + li {
    border-left: 1px solid #28dfff;
  }
  .el-pagination .btn-prev {
    width: 38px;
    height: 38px;
    margin-right: 34px;
    border: 1px solid #e3f6ff;
    border-radius: 6px;
    background: url("../../assets/imgs/icon_page.png") no-repeat center 0;
    i {
      display: none;
    }
  }
  .el-pagination .btn-next {
    width: 38px;
    height: 38px;
    margin-left: 34px;
    border: 1px solid #e3f6ff;
    border-radius: 6px;
    background: url("../../assets/imgs/icon_page.png") no-repeat center -44px;
    i {
      display: none;
    }
  }
  .el-pagination__sizes {
    height: 30px !important;
    line-height: 30px !important;
    margin-left: 170px;
    .el-input--mini .el-input__inner {
      height: 36px;
      line-height: 36px;
    }
  }
  .el-pagination__jump {
    height: 30px !important;
    line-height: 30px !important;
    margin-left: 10px;
    font-size: 16px !important;
    color: #969696;
    .el-input--mini .el-input__inner {
      height: 36px;
      line-height: 36px;
    }
  }
}
</style>
